﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Finance.Web
{
    public class Utils
    {
        public static ActionResult AngularFormErrors(Controller ctrl)
        {
            JsonResult result = new JsonResult();
            if (!ctrl.ModelState.IsValid)
            {
                ctrl.Response.StatusCode = 500;
                result.Data = ctrl.ModelState.Where(i => i.Value.Errors != null && i.Value.Errors.Count != 0).ToList();
            }

            return result;
        }
    }
}